<template>
  <div class="feature-page">
    <!-- 标题区 -->
    <div class="page-header">
      <h2 class="title">系统功能管理</h2>
      <p class="subtitle">可灵活配置平台功能开关</p>
    </div>

    <!-- 功能卡片网格 -->
    <div class="feature-grid">
      <div v-for="(feature, index) in features" :key="index" class="feature-card">
        <div class="card-header">
          <span class="feature-icon">
            <el-icon><SwitchButton /></el-icon>
          </span>
          <div class="feature-info">
            <h3>{{ feature.name }}</h3>
            <p>{{ feature.desc }}</p>
          </div>
          <el-switch
            v-model="feature.enabled"
            active-color="#13ce66"
            inactive-color="#dcdfe6"
            @change="handleToggle(feature)"
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { SwitchButton } from '@element-plus/icons-vue';

const features = ref([
  {
    name: '百度订单同步',
    desc: '开启后将自动同步百度平台订单到系统',
    enabled: true
  },
  {
    name: '拼多多订单同步',
    desc: '开启后将自动同步拼多多订单',
    enabled: false
  },
  {
    name: '淘宝订单同步',
    desc: '开启后将自动同步淘宝订单',
    enabled: false
  },
  {
    name: '短信通知',
    desc: '订单变更后发送短信通知客户',
    enabled: false
  },
  {
    name: '邮件通知',
    desc: '订单变更后发送邮件通知客户',
    enabled: false
  },
  {
    name: '库存预警',
    desc: '库存低于预设阈值时自动提醒',
    enabled: false
  }
]);

// 切换功能开关
const handleToggle = (feature) => {
  console.log(`${feature.name} 状态:`, feature.enabled ? '开启' : '关闭');
};
</script>

<style lang="scss" scoped>
.feature-page {
  padding: 24px;

  .page-header {
    margin-bottom: 24px;

    .title {
      font-size: 22px;
      font-weight: 600;
      color: #2c3e50;
    }

    .subtitle {
      font-size: 14px;
      color: #888;
      margin-top: 4px;
    }
  }

  .feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
  }

  .feature-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;

    &:hover {
      transform: translateY(-3px);
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    }

    .card-header {
      display: flex;
      align-items: center;
      justify-content: space-between;

      .feature-icon {
        width: 36px;
        height: 36px;
        border-radius: 10px;
        background: #f5f7fa;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 12px;
        font-size: 20px;
        color: #409eff;
      }

      .feature-info {
        flex: 1;
        h3 {
          margin: 0;
          font-size: 16px;
          font-weight: 600;
          color: #333;
        }
        p {
          margin: 4px 0 0;
          font-size: 13px;
          color: #666;
        }
      }
    }
  }
}
</style>
